<?php
/**
 * Phlix_Options
 * This is basically just a glorified array. Pass this to a Phlix object
 * or just pass in an array and it will be converted to a Phlix_Options object.
 * 
 * I actually should just use an array. This is overkill for the purpose. I will
 * probably end up getting rid of this class eventually and just use an array. Who
 * knows, it could become useful so I'll keep it for now.
 * 
 * @package Phlix
 * @copyright Luke Visinoni (luke.visinoni@gmail.com)
 * @author Luke Visinoni (luke.visinoni@gmail.com)
 * @license GNU Lesser General Public License
 */
class Phlix_Options implements ArrayAccess {

    /**
     * This class is basically just a wrapper around this array
     */
    protected $options;
    /**
     * Initialize the options object with an array
     */
    public function __construct($array = array()) {
    
        $this->options = $array;
    
    }
    /**
     * Determine if an offset exists
     */
    public function offsetExists($offset) {
    
        return array_key_exists($offset, $this->options);
    
    }
    /**
     * Retrieve element at offset
     */
    public function offsetGet($offset) {
    
        if (!$this->offsetExists($offset)) {
            throw new Phlix_Exception_Option("Offset '$offset' doesn't exist.");
        }
        return $this->options[$offset];
    
    }
    /**
     * Set element at offset
     */
    public function offsetSet($offset, $value) {
    
        $this->options[$offset] = $value;
    
    }
    /**
     * Unset element at offset
     */
    public function offsetUnset($offset) {
    
        unset($this->options[$offset]);
    
    }
    /**
     * Magic setter
     */
    public function __set($key, $value) {

        $this->offsetSet($key, $value);

    }
    /**
     * Magic getter
     */
    public function __get($key) {

        return $this->offsetGet($key);

    }
    /**
     * Magic isset
     */
    public function __isset($key) {

        return $this->offsetExists($key);

    }
    /**
     * Magic unset
     */
    public function __unset($key) {

        return $this->offsetUnset($key);

    }

}